import { http } from "@/utils/http";
import { baseUrlApi } from "@/api/utils";
import { message } from "@/utils/message";
type Result = {
	current_page : number;
	result ?: any;
	per_page ?: number;
	total ?: number;
	data ?: any;
};
type ResultDelete = {
	code : number;
	msg : string;
};
type ResultCreate = {
	code : number;
	msg : string;
};
type Show = {
	code : number;
	msg : string;
	result ?: any;
};

/**
 * 通知配置API
 * ###################
 * 增删改查详情
 * */
/** 通知配置列表 */
export const getAlarmConfigListApi = (params ?: object) => {
	return http.request<Result>("get", "/alarmConfig/list", {
		params
	});
};
/** 通知配置添加*/
export const createAlarmConfigApi = (data ?: object) => {
	return http.request<ResultCreate>("post", "/alarmConfig/store", {
		data
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知配置修改 */
export const updateAlarmConfigApi = (data ?: object) => {
	return http.request<ResultCreate>("put", "/alarmConfig/update", {
		data
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知配置删除 */
export const delAlarmConfigApi = (params ?: object) => {
	return http.request<ResultDelete>("delete", "/alarmConfig/delete", {
		params
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知配置详情 */
export const getAlarmConfigShowApi = (params ?: object) => {
	return http.request<Show>("get", "/alarmConfig/show", {
		params
	});
};
/** 通知配置选择 */
export const getAlarmConfigSelectApi = (params ?: object) => {
	return http.request<Result>("get", "/alarmConfig/select", {
		params
	});
};
/**
 * 通知行为API
 * ###################
 * 增删改查详情
 * */
/** 通知行为列表 */
export const getAlarmBehaveListApi = (params ?: object) => {
	return http.request<Result>("get", "/alarmBehave/list", {
		params
	});
};
/** 通知行为添加*/
export const createAlarmBehaveApi = (data ?: object) => {
	return http.request<ResultCreate>("post", "/alarmBehave/store", {
		data
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知行为修改 */
export const updateAlarmBehaveApi = (data ?: object) => {
	return http.request<ResultCreate>("put", "/alarmBehave/update", {
		data
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知行为删除 */
export const delAlarmBehaveApi = (params ?: object) => {
	return http.request<ResultDelete>("delete", "/alarmBehave/delete", {
		params
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知行为详情 */
export const getAlarmBehaveShowApi = (params ?: object) => {
	return http.request<Show>("get", "/alarmBehave/show", {
		params
	});
};
/** 通知行为选择 */
export const getAlarmBehaveSelectApi = (params ?: object) => {
	return http.request<Result>("get", "/alarmBehave/select", {
		params
	});
};
/**
 * 通知策略API
 * ###################
 * 增删改查详情
 * */
/** 通知配置列表 */
export const getAlarmTacticListApi = (params ?: object) => {
	return http.request<Result>("get", "/alarmTactic/list", {
		params
	});
};
/** 通知配置添加*/
export const createAlarmTacticApi = (data ?: object) => {
	return http.request<ResultCreate>("post", "/alarmTactic/store", {
		data
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知配置修改 */
export const updateAlarmTacticApi = (data ?: object) => {
	return http.request<ResultCreate>("put", "/alarmTactic/update", {
		data
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知配置删除 */
export const delAlarmTacticApi = (params ?: object) => {
	return http.request<ResultDelete>("delete", "/alarmTactic/delete", {
		params
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 通知配置详情 */
export const getAlarmTacticShowApi = (params ?: object) => {
	return http.request<Show>("get", "/alarmTactic/show", {
		params
	});
};
/**
 * 通知记录API
 * ###################
 * 删改查详情
 * */
/** 通知记录列表 */
export const getAlarmRecordApi = (params ?: object) => {
	return http.request<Result>("get", "/alarmRecord/list", {
		params
	});
};
/** 通知记录详情 */
export const getAlarmRecordShowApi = (params ?: object) => {
	return http.request<Show>("get", "/alarmRecord/show", {
		params
	});
};
/** 通知记录删除 */
export const delAlarmRecordApi = (params ?: object) => {
	return http.request<ResultDelete>("delete", "/alarmRecord/delete", {
		params
	}).catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};